from QQLoginTool.QQtool import OAuthQQ
from django.test import TestCase

# Create your tests here.
from rest_framework.response import Response
from rest_framework.views import APIView


class QQauthURLView(APIView):
    """拼接QQ登录网址"""

    def get(self, request):
        # 提取前端传入的next参数记录用户从哪里到的login界面
        next = request.query_params.get('next') or '/'
        # 2.利用QQ登录SDK
        oauth = OAuthQQ()
        login_url = oauth.get_qq_url()
        # 创建QQ工具对象
        # 调用它里面的方法 拼接好QQ登录网址
        return Response({'login_url': login_url, 'next': next})
